package com.lby.rabbitmq.listener;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @ClassName DirecBindListener
 * @Description TODO
 * @Author louby0923
 * @Date 2024/2/2 10:15
 * @Version 1.0
 */
@Component
public class DirecBindListener {

    // 基于注解来声明队列和交换机
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "lby.direct.queue1"),
            exchange = @Exchange(name = "lby.direct"),
            key = "1"))
    public void direct1(String msg) {
        System.out.println("lby.direct.queue1 = " + msg);
    }


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "lby.direct.queue2"),
            exchange = @Exchange(name = "lby.direct"),
            key = "2"))
    public void direct2(String msg) {
        System.out.println("lby.direct.queue2 = " + msg);
    }

}
